<!--
 * @Author: LiuYan
 * @Date: 2023-01-04 11:01:23
 * @LastEditors: LiuYan
 * @LastEditTime: 2023-01-05 10:30:29
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <link rel="stylesheet" href="./common/css/coommon.css" />
    <link
      href="https://cdn.bootcdn.net/ajax/libs/wangeditor5/5.1.23/css/style.min.css"
      rel="stylesheet"
    />
    <style>
      #editor—wrapper {
        border: 1px solid #ccc;
        z-index: 100;
        /* 按需定义 */
      }

      #toolbar-container {
        border-bottom: 1px solid #ccc;
      }

      #editor-container {
        height: 500px;
      }
    </style>
  </head>
  <body>
    <div class="additionalMaterial_all" id="app" style="height: 110vh">
      <div id="tabs" class="tabs">
        <div @click="jumpToPage(item)" class="tab-item" v-for="item in tabs">
          {{ item.name}}
        </div>
      </div>
      <iframe
        id="basicSetup"
        v-show="pathName == '基本设置'"
        src="./供应商(基本设置).html"
        frameborder="0"
        width="100%"
        height="100%"
        allowtransparency="true"
        style="background-color: transparent"
      ></iframe>
      <iframe
        id="productParameter"
        v-show="pathName == '产品参数'"
        src="./供应商(产品).html"
        frameborder="0"
        width="100%"
        height="100%"
        allowtransparency="true"
        style="background-color: transparent"
      ></iframe>
    </div>
  </body>
  <script src="./common/js/vue.js"></script>
  <script type="module">
    import Tabs from "./common/js/tabs.js";
    const { createApp } = Vue;
    createApp({
      data() {
        return {
          pathName: "基本设置",
          tabs: [
            {
              name: "基本设置",
            },
            {
              name: "产品参数",
            },
            {
              name: "功能特性",
            },
            {
              name: "技术参数",
            },
            {
              name: "检测报告",
            },
          ],
        };
      },
      methods: {
        jumpToPage(item) {
          this.pathName = item.name;
        },
      },
    }).mount("#app");
    let tabs = new Tabs({
      tabsEl: "#tabs",
      tabsItemEl: ".tab-item",
      index: 0,
      watch: ({ item, active, index, all, left }) => {
        all.forEach((item) => {
          item.style.color = "#4e5969";
        });
        all[index].style.color = "#3E7BFA";
        active.style.width = "80px";
        const { height, width } = active.getBoundingClientRect();
        active.style.left = left + (item.width - width) / 2 + "px";
        active.style.top = item.height - height + "px";
      },
    });
    function save() {
      let basicSetup = document.getElementById("basicSetup").contentWindow;
      let productParameter =
        document.getElementById("productParameter").contentWindow;
      return {
        html: productParameter.save(),
        ...basicSetup.save(),
      };
    }
    window.save = save;
  </script>
</html>
